package cn.udrm.water.base.v1.waterdistribute.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.EntityGraph.EntityGraphType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import cn.udrm.water.base.v1.waterdistribute.entities.WaterGateVendor;

@Repository
public interface WaterGateVendorRepository extends JpaRepository<WaterGateVendor, String>
			, JpaSpecificationExecutor<WaterGateVendor>{
	
	@EntityGraph(value="WaterGateVendor.all", type=EntityGraphType.FETCH)
	public Page<WaterGateVendor> findAll(Specification<WaterGateVendor> specification, Pageable pageable);
	
	@Query(value="FROM WaterGateVendor")
	public List<WaterGateVendor> findAllSelf();
	
	@EntityGraph(value="WaterGateVendor.all", type=EntityGraphType.FETCH)
	public List<WaterGateVendor> findAll();
	
	@Query(value="FROM WaterGateVendor w WHERE w.id=?1")
	@EntityGraph(value="WaterGateVendor.all", type=EntityGraphType.FETCH)
	public WaterGateVendor findAllWithWaterGates(String id);
	
	@Query(value="FROM WaterGateVendor w WHERE w.id=?1")
	@EntityGraph(value="WaterGateVendor.all", type=EntityGraphType.FETCH)
	public WaterGateVendor findAllById(String id);
	
	@Query(value="FROM WaterGateVendor w WHERE w.id=?1")
	public WaterGateVendor findSelfById(String id);

}
